package tetris.features;

import java.util.ArrayList;

import tetris.simulator.State;

public class HoleDepthFeature extends Feature{
  public ArrayList<Double> getFeatureVector(State tetrisState) {
    ArrayList<Double> featureVector = new ArrayList<Double>();
    int sumHoleDepth = 0;
    for (int i = 0; i < tetrisState.getTop().length; i++) {
      int filledCells = 0;
      for (int j = tetrisState.getTop()[i] - 1; j >= 0; j--) {
        if (tetrisState.getField()[j][i] == 0)
          sumHoleDepth += filledCells;
        else
          filledCells++;
      }
    }
    featureVector.add(new Double(sumHoleDepth));
    return featureVector;
  }
}
